
$(function () {
    $("#jqGrid").jqGrid({
        url: '../logMailHis/list',
        datatype: "json",
        colModel: [
			//{ label: 'oid', name: 'oid', width: 50, key: true ,},
			//{ label: 'emailFrom', name: 'emailFrom', width: 80 },
			{ label: '收件人', name: 'emailTo', width: 80 },
			{ label: '类别', name: 'type', width: 40 ,formatter: function(value, options, row){
                if(value == 'tableValidate'){
                    return '表验证';
                }
            }},
			{ label: '主题', name: 'subject', width: 60 },
			{ label: '邮件内容', name: 'emailText', width: 160 },
			{ label: '发送时间', name: 'sendTime', width: 60 }
        ],
		viewrecords: true,
        height: 800,
        rowNum: 5,
		rowList : [5,10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.data",
            page: "page.pageNo",
            total: "page.pageCount",
            records: "page.count"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		
	},
	methods: {
		update: function (event) {
			var oid = getSelectedRow();
			if(oid == null){
				return ;
			}
			
			location.href = "logMailHis_add.html?oid="+oid;
		},
		del: function (event) {
			var oids = getSelectedRows();
			if(oids == null){
				return ;
			}
			
			confirm('确定要删除选中的记录？', function(){
				$.ajax({
					type: "POST",
				    url: "../logMailHis/delete",
				    data: JSON.stringify(oids),
				    success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								$("#jqGrid").trigger("reloadGrid");
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		}
	}
});
